﻿<UserControl x:Class="CncSimple.View.MainScreen"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:MainViewModel="clr-namespace:CncConvProg.ViewModel.MainViewModel;assembly=CncConvProg.ViewModel" xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" xmlns:TreeViewModel="clr-namespace:CncConvProg.ViewModel.AuxViewModel.TreeViewModel;assembly=CncConvProg.ViewModel" xmlns:GraphicViewer="clr-namespace:GraphicViewer;assembly=GraphicViewer" xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop" xmlns:Controls1="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended" xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" xmlns:DummyViewModels="clr-namespace:CncConvProg.ViewModel.DummyViewModel;assembly=CncConvProg.ViewModel" mc:Ignorable="d" 
             d:DesignHeight="768" d:DesignWidth="1024" xmlns:Resources="clr-namespace:MecPrev.Resources;assembly=MecPrev.Resources" xmlns:avalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit" xmlns:ap="clr-namespace:CncSimple.View.AttachedProperty">    <!--<UserControl.Resources>
        <MainViewModel:MainPageViewModelLocator x:Key="viewModelLocator"  />
    </UserControl.Resources>-->
    <!--<UserControl.DataContext>
        <Binding Source="{StaticResource viewModelLocator}" Path="ViewModel" />
    </UserControl.DataContext>-->
    <Controls1:BusyIndicator DataContext="{Binding Path=Mvm}" BusyContent="Please Wait.." Grid.Row="1" IsBusy="{Binding Path=IsBusy}" DisplayAfter="0" d:DataContext="{Binding Source={StaticResource viewModel1}}" >
        <Controls1:BusyIndicator.Resources>
            <!--<DummyViewModels:MainScreenDummyViewModel x:Key="viewModel1" />-->
        </Controls1:BusyIndicator.Resources>
        <Controls1:BusyIndicator.BusyContentTemplate>
            <DataTemplate>
                <StackPanel Margin="4">
                    <TextBlock Text="Calculating" FontWeight="Bold" HorizontalAlignment="Center"/>
                    <StackPanel Margin="4">
                        <TextBlock Text="Please Wait..."/>
                        <ProgressBar Value="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor},
                            Path=DataContext.WaitScreenCurrent}" Height="15" Minimum="0" Maximum="100"/>
                    </StackPanel>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </StackPanel>
            </DataTemplate>
        </Controls1:BusyIndicator.BusyContentTemplate>
        <Controls1:BusyIndicator.ProgressBarStyle>
            <Style TargetType="ProgressBar">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Style>
        </Controls1:BusyIndicator.ProgressBarStyle>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ribbon:Ribbon Title="{Binding Path=FilePath}">
                <ribbon:Ribbon.ApplicationMenu>
                    <ribbon:RibbonApplicationMenu Label="File" SmallImageSource="pack://application:,,,/CncConvProg.View;component/Images/sampleImage.png" >
                        <ribbon:RibbonApplicationMenuItem  ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/newFile.png" Header="_New File"
                                                           Command="{Binding Path=DataContext.NewFileCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"/>
                        <ribbon:RibbonApplicationMenuItem  ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/openFile.png" Header="_Open" 
                                                           Command="{Binding Path=DataContext.OpenFileDialogCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"/>
                        <ribbon:RibbonApplicationMenuItem  ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/save.png" Header="_Save" Command="{Binding Path=SaveCmd}"/>
                        <ribbon:RibbonApplicationMenuItem  ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/save.png" Header="Sa_ve As" Command="{Binding Path=SaveFileDialogCmd}"/>
                        <ribbon:RibbonApplicationMenuItem  ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/preference.png" Header="Program Preference" 
                                                           Command="{Binding Path=DataContext.OpenDialogCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                                           CommandParameter="{x:Static Member=MainViewModel:DialogEnum.ProgramPreference}"/>
                        <ribbon:RibbonApplicationMenuItem  ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/preference.png" Header="Unit Selection" 
                                                           Command="{Binding Path=DataContext.OpenDialogCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                                           CommandParameter="{x:Static Member=MainViewModel:DialogEnum.UnitSelection}"/>
                    </ribbon:RibbonApplicationMenu>
                </ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonTab Header="Home">
                    <ribbon:RibbonGroup Header="File">
                        <ribbon:RibbonButton  LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/newFile.png" Label="{x:Static Resources:GuiRes.NewFile}" Command="{Binding Path=DataContext.NewFileCmd, 
                            RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}" />
                        <ribbon:RibbonButton  SmallImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/openFile.png" Label="{x:Static Resources:GuiRes.OpenFile}" Command="{Binding Path=DataContext.OpenFileDialogCmd,
                            RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}" />
                        <ribbon:RibbonButton  SmallImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/save.png" Label="{x:Static Resources:GuiRes.Save}" Command="{Binding Path=SaveCmd}"/>
                        <ribbon:RibbonButton  SmallImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/save.png" Label="{x:Static Resources:GuiRes.SaveAs}" Command="{Binding Path=SaveFileDialogCmd}"/>
                    </ribbon:RibbonGroup>
                    <ribbon:RibbonGroup Header="Article">
                        <ribbon:RibbonMenuButton Label="{x:Static Resources:GuiRes.NewPhase}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/addPhase.png"
                                        >
                            <ribbon:RibbonMenuButton.Resources>
                                <Style x:Key="newPhaseItemContainerStyle">
                                    <Setter Property="MenuItem.Header" Value="{Binding Path=MachineName}"/>
                                    <Setter Property="MenuItem.Command" Value="{Binding DataContext.AddPhaseCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"/>
                                    <Setter Property="MenuItem.CommandParameter" Value="{Binding}"/>
                                </Style>
                            </ribbon:RibbonMenuButton.Resources>
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.Lathe2Ax}" 
                                                   ItemsSource="{Binding Path=DataContext.HorizontalLatheMachines, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                                   ItemContainerStyle="{StaticResource ResourceKey=newPhaseItemContainerStyle}"  />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.Lathe3Ax}" 
                                                   ItemsSource="{Binding Path=DataContext.Lathe3AxisMachines, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                                   ItemContainerStyle="{StaticResource ResourceKey=newPhaseItemContainerStyle}"  />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.VerticalMill}"
                                                   ItemsSource="{Binding Path=DataContext.MillMachines, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                                   ItemContainerStyle="{StaticResource ResourceKey=newPhaseItemContainerStyle}"  />
                        </ribbon:RibbonMenuButton>

                    </ribbon:RibbonGroup>
                    <ribbon:RibbonGroup Header="">
                        <ribbon:RibbonMenuButton 
                                        Label="{x:Static Resources:GuiRes.Tabelle}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Gui/Table.png"
                                         >
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.ToolDialog}"
                                         ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/ttools.png"
                                         Command="{Binding Path=DataContext.OpenDialogCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                         CommandParameter="{x:Static Member=MainViewModel:DialogEnum.UtensiliDialogo}"
                                         />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.dlgTabellaFilettature}"
                                        ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/ttable.png"
                                         Command="{Binding Path=DataContext.OpenDialogCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                        CommandParameter="{x:Static Member=MainViewModel:DialogEnum.TabellaFilettatura}"
                                            />


                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.MachinesDialog}"
                                        ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/ttools.png"
                                         Command="{Binding Path=DataContext.OpenDialogCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                        CommandParameter="{x:Static Member=MainViewModel:DialogEnum.MacchineDialogo}"
                                            />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.MaterialDialog}"
                                        ImageSource="pack://application:,,,/CncConvProg.View;component/Images/gui/ttools.png"
                                         Command="{Binding Path=DataContext.OpenDialogCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
                                        CommandParameter="{x:Static Member=MainViewModel:DialogEnum.MaterialiDialogo}"
                                            />
                        </ribbon:RibbonMenuButton>
                    </ribbon:RibbonGroup>
                    <ribbon:RibbonGroup Header="{x:Static Resources:GuiRes.DrillingOp}">
                        <ribbon:RibbonMenuButton Label="{x:Static Resources:GuiRes.DrillingOp}" LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/drill.png">
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.SimpleDrilling}"  Command="{Binding Path=NewWorkCmd}" CommandParameter="{x:Static Member=MainViewModel:EnumWork.ForaturaSemplice}" />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.Tapping}" Command="{Binding Path=NewWorkCmd}" CommandParameter="{x:Static Member=MainViewModel:EnumWork.Maschiatura}" />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.Reamering}" Command="{Binding Path=NewWorkCmd}" CommandParameter="{x:Static Member=MainViewModel:EnumWork.Alesatura}" />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.Boring}" Command="{Binding Path=NewWorkCmd}" CommandParameter="{x:Static Member=MainViewModel:EnumWork.Barenatura}" />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.Counterboring}" Command="{Binding Path=NewWorkCmd}"  CommandParameter="{x:Static Member=MainViewModel:EnumWork.Lamatura}" />
                            <ribbon:RibbonMenuItem Header="{x:Static Resources:GuiRes.MillThreadOp}"
                                        ImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/drill.png"
                                        Command="{Binding Path=NewWorkCmd}" 
                                        CommandParameter="{x:Static Member=MainViewModel:EnumWork.FresaturaFilettare}" />
                        </ribbon:RibbonMenuButton>
                    </ribbon:RibbonGroup>


                    <ribbon:RibbonGroup Header="{x:Static Resources:GuiRes.Mill}">
                        <ribbon:RibbonButton Label="{x:Static Resources:GuiRes.FaceMilling}"
                                         LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/MillFace_32.png"
                                         Command="{Binding Path=NewWorkCmd}"
                                          CommandParameter="{x:Static Member=MainViewModel:EnumWork.FresaturaSpianatura}"
                                         />
                        <ribbon:RibbonButton
                                        Label="{x:Static Resources:GuiRes.ContourOp}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/millCont_32.png"
                                        Command="{Binding Path=NewWorkCmd}" 
                                         CommandParameter="{x:Static Member=MainViewModel:EnumWork.FresaturaContornatura}"
                                        />
                        <ribbon:RibbonButton
                                        Label="{x:Static Resources:GuiRes.PocketOp}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/millCava_32.png"
                                        Command="{Binding Path=NewWorkCmd}" 
                                        CommandParameter="{x:Static Member=MainViewModel:EnumWork.FresaturaCava}"
                                        />

                        <ribbon:RibbonButton
                                        Label="{x:Static Resources:GuiRes.SlotOp}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/millScanaCerchio_32.png"
                                        Command="{Binding Path=NewWorkCmd}" 
                                        CommandParameter="{x:Static Member=MainViewModel:EnumWork.FresaturaScanalaturaChiusa}"
                                        />
                        <ribbon:RibbonButton
                                        Label="{x:Static Resources:GuiRes.SideOp}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/millLine.png"
                                        Command="{Binding Path=NewWorkCmd}" 
                                        CommandParameter="{x:Static Member=MainViewModel:EnumWork.FresaturaLato}"
                                        />
                        <ribbon:RibbonButton
                                        Label="{x:Static Resources:GuiRes.OpenSlot}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/millScan.png"
                                        Command="{Binding Path=NewWorkCmd}" 
                                        CommandParameter="{x:Static Member=MainViewModel:EnumWork.FresaturaScanalaturaLinea}"
                                        />
                        <ribbon:RibbonButton
                                        Label="Text Engraving"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Work/textEngraving.png"
                                        Command="{Binding Path=NewWorkCmd}" 
                                        CommandParameter="{x:Static Member=MainViewModel:EnumWork.TextEngraving}"
                                        />

                    </ribbon:RibbonGroup>

                    <ribbon:RibbonGroup Header="Result">
                        <ribbon:RibbonButton Label="{x:Static Resources:GuiRes.btnCalculate}"
                                        LargeImageSource="pack://application:,,,/CncConvProg.View;component/Images/Gui/generateCode.png"
                                         Command="{Binding Path=GenerateCodeCmd}"
                                            >
                        </ribbon:RibbonButton>
                    </ribbon:RibbonGroup>
                </ribbon:RibbonTab>
            </ribbon:Ribbon>

            <ad:DockingManager x:Name="dockManager" Grid.Row="1" Padding="5">
                <ad:ResizingPanel Orientation="Horizontal">
                    <ad:DockablePane ad:ResizingPanel.ResizeWidth=".3*">
                        <ad:DockableContent>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="50" />
                                    <RowDefinition Height="Auto"  />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{x:Static Resources:GuiRes.ParamMaterial}" VerticalAlignment="Center" Width="150" TextWrapping="Wrap" FontSize="16" />
                                        <ComboBox ItemsSource="{Binding Path=Materiali}" SelectedItem="{Binding Path=Materiale}"
                                                Height="30"
                                                Margin="2" 
                                                MinWidth="150">
                                            <ComboBox.ItemTemplate>
                                                <DataTemplate>
                                                    <Border >
                                                        <StackPanel Orientation="Horizontal">
                                                            <Image >
                                                                <Image.Style>
                                                                    <Style>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding Path=GruppoMateriale}" Value="0">
                                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_p.png"/>
                                                                            </DataTrigger>

                                                                            <DataTrigger Binding="{Binding Path= GruppoMateriale}" Value="1">
                                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_m.png"/>
                                                                            </DataTrigger>

                                                                            <DataTrigger Binding="{Binding Path=GruppoMateriale}" Value="2">
                                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_k.png"/>
                                                                            </DataTrigger>

                                                                            <DataTrigger Binding="{Binding Path= GruppoMateriale}" Value="3">
                                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_n.png"/>
                                                                            </DataTrigger>

                                                                            <DataTrigger Binding="{Binding Path=GruppoMateriale}" Value="4">
                                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_h.png"/>
                                                                            </DataTrigger>

                                                                            <DataTrigger Binding="{Binding Path= GruppoMateriale}" Value="5">
                                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_s.png"/>
                                                                            </DataTrigger>

                                                                            <DataTrigger Binding="{Binding Path= GruppoMateriale}" Value="6">
                                                                                <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/Material/mat_n.png"/>
                                                                            </DataTrigger>

                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </Image.Style>
                                                            </Image>
                                                            <TextBlock Text="{Binding Path=Descrizione}" VerticalAlignment="Center" Margin="3"/>
                                                        </StackPanel>
                                                    </Border>
                                                </DataTemplate>
                                            </ComboBox.ItemTemplate>
                                        </ComboBox>
                                    </StackPanel>
                                </StackPanel>
                                <TextBlock Text="Ciclo di lavorazione :" Grid.Row="1" FontSize="16" />
                                <TreeView Grid.RowSpan="1" Grid.Row="2" ItemsSource="{Binding Path=TreeView}" dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{Binding}" >
                                    <TreeView.Resources>
                                        <SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF" />
                                        <SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />
                                        <HierarchicalDataTemplate DataType="{x:Type DummyViewModels:FaseDummyVm}"  ItemsSource="{Binding Children}" >
                                            <Border  Margin="2,2,2,0" >
                                                <Border.Style>
                                                    <Style>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                                                <Setter Property="Border.BorderThickness" Value="1"/>
                                                                <Setter Property="Border.BorderBrush" Value="Red"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Border.Style>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Path=Label}" FontSize="16" MinWidth="180"/>
                                                    <Button Content="Edit" 
                                        Command="{Binding DataContext.EditPhaseDetailCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Button Content="Del" 
                                        Command="{Binding DataContext.DelWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Image Width="16" Height="16" Margin="1" HorizontalAlignment="Left" VerticalAlignment="Center">
                                                        <Image.Style>
                                                            <Style>
                                                                <Style.Triggers>
                                                                    <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                                                        <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/errorMark_16.png"/>
                                                                    </DataTrigger>
                                                                </Style.Triggers>
                                                            </Style>
                                                        </Image.Style>
                                                    </Image>
                                                </StackPanel>
                                            </Border>

                                        </HierarchicalDataTemplate>

                                        <HierarchicalDataTemplate DataType="{x:Type TreeViewModel:FaseLavoroTreeView}"  ItemsSource="{Binding Children}" >
                                            <Border  Margin="2,2,2,0" >
                                                <Border.Style>
                                                    <Style>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                                                <Setter Property="Border.BorderThickness" Value="1"/>
                                                                <Setter Property="Border.BorderBrush" Value="Red"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Border.Style>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Path=Label}" FontSize="16" MinWidth="180"/>
                                                    <Button Content="Edit" 
                                        Command="{Binding DataContext.EditPhaseDetailCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Button Content="Del" 
                                        Command="{Binding DataContext.DelWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Image Width="16" Height="16" Margin="1" HorizontalAlignment="Left" VerticalAlignment="Center">
                                                        <Image.Style>
                                                            <Style>
                                                                <Style.Triggers>
                                                                    <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                                                        <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/errorMark_16.png"/>
                                                                    </DataTrigger>
                                                                </Style.Triggers>
                                                            </Style>
                                                        </Image.Style>
                                                    </Image>
                                                </StackPanel>
                                            </Border>

                                        </HierarchicalDataTemplate>

                                        <DataTemplate DataType="{x:Type DummyViewModels:DummtLavVm}">
                                            <Border Margin="2,2,2,0">
                                                <StackPanel Orientation="Horizontal">
                                                    <StackPanel Orientation="Horizontal" MinWidth="180">
                                                        <!--<TextBlock Text="{Binding Path=LavorazionePosition}" FontSize="14"/>-->
                                                        <Image Source="{Binding Path=IconSource}" Height="16" Width="16" Margin="5,0,5,0"/>
                                                        <TextBlock Text="{Binding Path=Label}"/>
                                                    </StackPanel>
                                                    <Button Content="Edit" 
                                        Command="{Binding DataContext.EditWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Button Content="Del" 
                                        Command="{Binding DataContext.DelWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Button Content="Clone" 
                                        Command="{Binding DataContext.CloneWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Image Width="16" Height="16" Margin="1" HorizontalAlignment="Left" VerticalAlignment="Center">
                                                        <Image.Style>
                                                            <Style>
                                                                <Style.Triggers>
                                                                    <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                                                        <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/errorMark_16.png"/>
                                                                    </DataTrigger>
                                                                    <!--<DataTrigger Binding="{Binding Path= IsValid}" Value="True">
                                                    <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/okCheck_16.png"/>
                                                </DataTrigger>-->
                                                                </Style.Triggers>
                                                            </Style>
                                                        </Image.Style>
                                                    </Image>

                                                </StackPanel>
                                            </Border>
                                        </DataTemplate>
                                        <DataTemplate DataType="{x:Type TreeViewModel:LavorazioneTreeView}">
                                            <Border Margin="2,2,2,0">
                                                <StackPanel Orientation="Horizontal">
                                                    <StackPanel Orientation="Horizontal" MinWidth="180">
                                                        <!--<TextBlock Text="{Binding Path=LavorazionePosition}" FontSize="14"/>-->
                                                        <Image Source="{Binding Path=IconSource}" Height="16" Width="16" Margin="5,0,5,0"/>
                                                        <TextBlock Text="{Binding Path=Label}"/>
                                                        <Image Width="16" Height="16" Margin="5,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Center">
                                                            <Image.Style>
                                                                <Style>
                                                                    <Style.Triggers>
                                                                        <DataTrigger Binding="{Binding Path= IsValid}" Value="False">
                                                                            <Setter Property="Image.Source" Value="pack://application:,,,/CncConvProg.View;component/Images/Gui/errorMark_16.png"/>
                                                                        </DataTrigger>
                                                                    </Style.Triggers>
                                                                </Style>
                                                            </Image.Style>
                                                        </Image>
                                                    </StackPanel>
                                                    <Button Content="Edit" 
                                        Command="{Binding DataContext.EditWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Button Content="Del" 
                                        Command="{Binding DataContext.DelWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>
                                                    <Button Content="Clone" 
                                        Command="{Binding DataContext.CloneWorkCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Controls1:BusyIndicator}, Mode=FindAncestor}}"
                                        CommandParameter="{Binding}"/>


                                                </StackPanel>
                                            </Border>
                                        </DataTemplate>
                                    </TreeView.Resources>
                                    <TreeView.ItemContainerStyle>
                                        <Style TargetType="{x:Type TreeViewItem}">
                                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                        </Style>
                                    </TreeView.ItemContainerStyle>
                                </TreeView>


                            </Grid>
                        </ad:DockableContent>
                    </ad:DockablePane>
                    <ad:DockablePane  ad:ResizingPanel.ResizeWidth=".35*">
                        <ad:DockableContent Title="Operation" >
                            <ad:ResizingPanel Orientation="Vertical">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="25" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Button Command="{Binding Path=SortOperationCmd}" >
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/sortOperation.png"/>
                                            <TextBlock Text="{x:Static Resources:GuiRes.SortOperation}"/>
                                        </StackPanel>
                                    </Button>
                                    <ListView Grid.Row="2"  ItemsSource="{Binding Path=OperationList}"  x:Name="listViewOperations"  dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"
                        dd:DragDrop.DropHandler="{Binding}" Grid.RowSpan="2">
                                        <ListView.View>
                                            <GridView  >
                                                <GridViewColumn Header="{x:Static Resources:GuiRes.Description}" DisplayMemberBinding="{Binding Path=Descrizione}" Width="130"/>
                                                <GridViewColumn Header="{x:Static Resources:GuiRes.ToolLabel}" DisplayMemberBinding="{Binding Path=ToolLabel}" Width="130"/>
                                                <GridViewColumn Header="#T" DisplayMemberBinding="{Binding Path=NumeroUtensile}" Width="35"/>
                                                <GridViewColumn Header="{x:Static Resources:GuiRes.Time}" DisplayMemberBinding="{Binding Path=OperationTime}" Width="65"/>
                                                <GridViewColumn Header="{x:Static Resources:GuiRes.ToolChange}">
                                                    <GridViewColumn.CellTemplate>
                                                        <DataTemplate>
                                                            <CheckBox Visibility="{Binding Path=IsToolChangeOptional}" IsChecked="{Binding Path=ForceToolChange}"/>
                                                        </DataTemplate>
                                                    </GridViewColumn.CellTemplate>
                                                </GridViewColumn>
                                            </GridView>
                                        </ListView.View>
                                    </ListView>
                                </Grid>
                                <GraphicViewer:Viewer3D Grid.Column="0" DataContext="{Binding Path = Preview}" Grid.Row="2" Grid.ColumnSpan="2" Background="White"/>
                            </ad:ResizingPanel>
                        </ad:DockableContent>
                    </ad:DockablePane>
                    <ad:DockablePane ad:ResizingPanel.ResizeWidth=".35*">
                        <ad:DockableContent Title="Result">
                            <avalonEdit:TextEditor  Name="textEditor1" Margin="5"  ShowLineNumbers="True" ap:AvalonEditorEx.BoundDocument="{Binding Path=ProgText, Mode=TwoWay}" Grid.Column="2" Grid.RowSpan="3" FontStretch="UltraExpanded" FontFamily="Segoe UI" FontStyle="Normal" FontSize="14" />
                        </ad:DockableContent>
                    </ad:DockablePane>
                </ad:ResizingPanel>
            </ad:DockingManager>

            <StatusBar Grid.Row="2" >
                <StatusBar.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="250"/>
                                <ColumnDefinition Width="4*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                        </Grid>
                    </ItemsPanelTemplate>
                </StatusBar.ItemsPanel>
                <StatusBarItem>
                </StatusBarItem>
                <StatusBarItem Grid.Column="1">
                </StatusBarItem>
                <StatusBarItem Grid.Column="2">

                </StatusBarItem>
                <StatusBarItem Grid.Column="3">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Unit : "/>
                        <TextBlock Text="{Binding Path=MeasureUnitLabel}"/>
                    </StackPanel>
                </StatusBarItem>

            </StatusBar>

        </Grid>
    </Controls1:BusyIndicator>
</UserControl>
